
#include "../include/Comm.hpp"
#include "../include/Util.hpp"

int main()
{
    Socket client;
    client.CreateClient(8888, "127.0.0.1");
    std::string requ = "PUT /1234.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
    std::string body;
    Util::ReadFile("hello.txt", &body);
    requ += ("Content-Length: " + std::to_string(body.size()) + "\r\n\r\n");
    
    assert(client.Send(requ.c_str(), requ.size()) != -1);
    assert(client.Send(body.c_str(), body.size()) != -1);
    ssize_t n;
    char buffer[1024] = {0};
    assert((n = client.Recv(buffer, sizeof buffer - 1)) != -1);
    buffer[n] = 0;
    std::cout << buffer << std::endl;
    sleep(3);
    client.Close();

    return 0;
}